<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- 数组转对象 -->
    <script type="text/javascript">
        var arr = ['a', 'a', 'a', 'b', 'b', 'c', 'c', 'c', 'c', 'd', 'd', 'd', 'd'];
        var obj = {};
        for (var i = 0; i < arr.length; i++) {
            var chars = arr.join("").charAt(i);
            if (obj[chars]) {
                obj[chars]++
            } else {
                obj[chars] = 1
            }
        }
        console.log(obj);
    </script>
</body>

</html>